/**
 * 
 */
package com.worksmap.core.task;

/** 
 * 公共资源类 
 */ 
public class PublicResource {
	private int number = 100;  
	  
    /** 
     * 增加公共资源 
     */  
    public synchronized void increace() {  
        while (number >= 10) {  
            try {  
                wait();  
            } catch (InterruptedException e) {  
                e.printStackTrace();  
            }  
        }  
        number++;  
        System.out.println("生产" + number);  
        notify();  
    }  
  
    /** 
     * 减少公共资源 
     */  
    public synchronized void decreace() {  
        while (number == 0) {  
            try {  
                wait();  
            } catch (InterruptedException e) {  
                e.printStackTrace();  
            }  
        }  
        number--;  
        System.out.println("消费" + number);  
        notify();  
    } 
}
